package com.whnk.pm.service.impl;

import java.util.List;

import com.whnk.pm.enums.VerifyEnum;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.whnk.common.annotation.CompScope;
import com.whnk.pm.domain.EmpInfo;
import com.whnk.pm.mapper.EmpInfoMapper;
import com.whnk.pm.service.IEmpInfoService;
import com.whnk.pm.service.IProjInfoService;

/**
 * 人员基本 服务层实现
 * 
 * @author whwhnk
 * @date 2019-06-13
 */
@Service
public class EmpInfoServiceImpl implements IEmpInfoService {
	
	@Autowired
	private EmpInfoMapper EmpInfoMapper;

	@Autowired
	private IProjInfoService iProjInfoService;

	/**
	 * 查询人员信息列表
	 * 
	 * @param empInfo
	 *            人员信息
	 * @return 人员信息集合
	 */
	@Override
	@CompScope(tableAlias = "b")
	public List<EmpInfo> selectEmpInfoList(EmpInfo empInfo) {
		List<EmpInfo> empInfoList = EmpInfoMapper.selectEmpInfoList(empInfo);
		empInfoList.stream().forEach(info -> {
			if (StringUtils.equals(info.getVerifyStatus(), VerifyEnum.VERIFY_OK_ENUM.getCode())) {
				info.setVerifyStatus(VerifyEnum.VERIFY_OK_ENUM.getMsg());
			} else {
				info.setVerifyStatus(VerifyEnum.VERIFY_NO_ENUM.getMsg());
			}
		});
		return empInfoList;
	}

	@Override
	public void statisticsInfo() {
		EmpInfo selectEmpInfo = new EmpInfo();
		List<EmpInfo> empInfoList = EmpInfoMapper.selectEmpInfoList(selectEmpInfo);
		for (EmpInfo empInfo : empInfoList) {
			String empId = empInfo.getEmpId();
			iProjInfoService.staticProject(empId);
		}
	}
}
